Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated this for ya! #5

Open
wants to merge 15 commits into
base: master
Choose a base branch
from
Open

Conversation

FashyGainz
Copy link

added concurrency
added better error handling
Made it possible to use cidr notation for scanning
added default nmapargs

1. New Argument (--nmapdatadir): Users can specify their own NSE script directory using this argument. If they don't, the script will look for it in default directories.

2. Directory Check: If the user provides a directory that doesn’t exist, the script will notify them and exit.

3. Dynamic NSE Script Path Detection: If no custom path is given, the script will try to locate it using common paths (/usr/local/share/nmap/scripts, /usr/share/nmap/scripts).

4. Error Handling for Missing Directories: If the script cannot find the NSE script directory, it will exit with an error message.
Function erroring out because it assumes nfsls4 exists which is risky af. The condition if len(nfsls) > 4 ensures that nfsls[4] exists before attempting to access it. This prevents the IndexError from being raised when nfsls has fewer elements.
moved the get_host_ranges method into the sniffer class, ensuring that it can be accessed using self.get_host_ranges() as expected
expand_cidr Method:

This method takes a CIDR notation (like 10.185.80.0/24) and expands it into individual IP addresses using the ipaddress module.
It handles errors if an invalid CIDR is provided.
Modified sniff_hosts:

When CIDR notation is detected in the hosts string, it expands the range using the expand_cidr method. This generates a list of individual IP addresses that can be scanned.
self.nm.all_hosts(): This method returns a list of all hosts that Nmap scanned and returned results for. If the target host (host) is not in this list, it means Nmap couldn't get any information for that host.
Logging: A warning is logged when Nmap does not return results for a host, which could help in debugging why a particular host was skipped.
Graceful Return: If the host is not in the scan results, the method returns the host and the empty open_ports dictionary, skipping further processing.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant